﻿using System;
using System.Runtime.Serialization;
using System.ServiceModel;

namespace SearchFrontEnd
{
    /// <summary>
    /// The definition of the interface exposed by the front end server to the
    /// clients. 
    /// </summary>
    [ServiceContract]
    public interface ISearchFrontEnd
    {
        /// <summary>
        /// Used by a client to index a certain page in the search engine.
        /// </summary>
        /// <param name="page">The page to be indexed.</param>
        [OperationContract]
        void Index(Page page);

        /// <summary>
        /// Used by a client to search for pages on the search engine that match
        /// the search criteria.
        /// </summary>
        /// <param name="words">list of words to search for.</param>
        /// <returns>A list of pages, where each page contains all the specified words,
        /// excluding stop words specified during the engine's initialization</returns>
        [OperationContract]
        string[] Search(String[] words);
    }

    /// <summary>
    /// Definition of the data contract for the Page class.
    /// This class represents a page that can be indexed by the 
    /// search engine's clients.
    /// </summary>
    [DataContract]
    public class Page
    {
        [DataMember]
        public String Name { get; set; }
        [DataMember]
        public String Content { get; set; }
    }
}
